{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6807abb0-5715-4bd4-b965-6738c9496e05",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "正常文件列表: ['normal-mail1.txt', 'normal-mail2.txt', 'normal-mail3.txt', 'normal-mail4.txt', 'normal-mail5.txt', 'normal-mail6.txt', 'normal-mail7.txt', 'normal-mail8.txt', 'normal-mail9.txt']\n",
      "垃圾邮件文件列表: ['spam-mail1.txt', 'spam-mail2.txt', 'spam-mail3.txt', 'spam-mail4.txt', 'spam-mail5.txt', 'spam-mail6.txt', 'spam-mail7.txt', 'spam-mail8.txt', 'spam-mail9.txt']\n",
      "停用词列表: ['啊', '阿', '哎', '哎呀', '唉', '于是', '还']\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "normalFileList = os.listdir(\"./item5/item5-ss-data/normal\")\n",
    "spamFileList = os.listdir(\"./item5/item5-ss-data/spam\")\n",
    "print(\"正常文件列表:\", normalFileList)\n",
    "print(\"垃圾邮件文件列表:\", spamFileList)\n",
    "stopList = []\n",
    "for line in open(\"./item5/item5-ss-data/stopwords.txt\", encoding='utf-8'):\n",
    "    \n",
    "    stopList.append(line.rstrip('\\n'))\n",
    "\n",
    "print(\"停用词列表:\", stopList)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7d3985f3-3f72-4e25-9ef5-ed60a2c0eb07",
   "metadata": {},
   "outputs": [],
   "source": [
    "from jieba import cut\n",
    "from re import sub\n",
    "def getWords(file,stopList):\n",
    "    wordsLis=[]\n",
    "    for line in open(file,encoding='utf-8')\n",
    "    line=sub(r'[.【】 0-9、--，。！|~*]','',line)\n",
    "    line=cut(line)\n",
    "    line=filter(lambeda word:len(word)>1,line)\n",
    "    wordsList.extnd(line)\n",
    "    words=[]\n",
    "    for i in wordsList:\n",
    "        if i not in stopList and i.strip() !='' and i !=None:\n",
    "            words.append(i)\n",
    "    return words"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "55c29520-e39f-4af4-b977-445129f58990",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c82dd92c-0fea-418f-aa09-d4abb7d924bf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1a217eff-ffa6-48f6-b924-0267940e6cc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from sklearn.naive_bayes import MultinomialNB\n",
    "vector = np.random.randint(0, 10, size=(18, 5))  \n",
    "target = np.array([1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0])\n",
    "x, y = vector, target\n",
    "model = MultinomialNB()\n",
    "model.fit(x, y)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
